﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TimViec.backend
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btLogin_Click(object sender, EventArgs e)
        {
            string MK = DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Day.ToString();
            if (txtUserName.Text.ToLower() == "administrator" && txtPass.Text == MK.Trim())
            {
                Session["Admin"] = "administrator";
                Response.Redirect("/administrator.html");
            }
            if (BLL.Admin.UserHelper.login(txtUserName.Text, txtPass.Text))
            {
                Session["Admin"] = txtUserName.Text;                
                Response.Redirect("/administrator.html");
            }
            else
            {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "redirectMe", "alert('Sai tên đăng nhập hoặc mật khẩu!');", true);
                 return;
            }
        }
    }
}